def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True

def closest_prime_number(num):
    num = int(num)
    if num < 100 or num > 999:
        print("Wrong input")
        return
    lower = num
    upper = num
    while True:
        if is_prime(lower):
            print(lower)
            return
        if is_prime(upper):
            print(upper)
            return
        lower -= 1
        upper += 1

words = input().split()
number = ""
for word in words:
    if word == "zero":
        number += "0"
    elif word == "one":
        number += "1"
    elif word == "two":
        number += "2"
    elif word == "three":
        number += "3"
    elif word == "four":
        number += "4"
    elif word == "five":
        number += "5"
    elif word == "six":
        number += "6"
    elif word == "seven":
        number += "7"
    elif word == "eight":
        number += "8"
    elif word == "nine":
        number += "9"
    else:
        print("Wrong input")
        exit()

closest_prime_number(number)
